<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <h1>商品添加页面</h1>
  <input type="text" placeholder="商品名称" v-model="product.title">
  <input type="text" placeholder="商品价格" v-model="product.price">
  <input type="text" placeholder="商品库存" v-model="product.num">
  <input type="submit" value="添加" @click="insertPro()">
</div>
<!--引入axios和vue框架文件-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
          product:{
            title:"",price:"",num:""
          }
        },
        methods:{
          insertPro(){
            axios.post("insert",v.product).then(function (response) {
              alert("添加成功");
              location.href = "list.html";
            })
          }

        }
    })
</script>
</body>
</html>